-- fairy_slime
-- created by zhuangsl
-- 仙女冈布奥触发事件

return {
    checkEvent = function(eventId, para)
        -- 召唤兽匹诺曹必须存活
        local dbase = SlimeEventM.query(eventId, "dbase") or {};
        local summonId = dbase["summon_id"] or 0;

        if SummonM.calcExistedSummon(summonId) > 0 then
            return true;
        end

        return false;
    end,

    triggerEvent = function(eventId, para)
        -- 先尝试扣除金币
        if not SlimeEventM.tryCost(eventId, para) then
            return false;
        end

        -- 找出召唤兽，上面检查过了不再检查
        local dbase = SlimeEventM.query(eventId, "dbase") or {};
        local summonId = dbase["summon_id"] or 0;
        local grid = SummonM.findSummonsByClassId(summonId)[1];
        local pos = grid:getPos();

        -- 干掉召唤兽并清除模型
        SummonM.summonDisappear(pos);
        EventMgr.fire(event.SUMMON_TRANS_BUILDING, {["pos"] = pos, ["needEffect"] = true, });

        -- 转化为建筑
        local element = dbase["element"];
        local class = DungeonM.queryElement(element, "class");
        DungeonM.transformGrid(class, pos, GRID_STATE_OPEN, {["element"] = element, });

        return true;
    end,
};

